package com.quanquan.store.repository;

import com.quanquan.store.entity.StoreCommercial;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @ClassName:StoreCommercialRepository
 * @Description:TODO
 * @Author:xiongjunbao
 * @Date:2019/3/12 17:59
 * @Version 1.0
 */
public interface StoreCommercialRepository extends JpaRepository<StoreCommercial,String> {

    /**
     * 通过业态id查找相关业态对应的商户
     *
     * @param commercialId
     * @param count
     * @param size
     * @return
     */
    @Query(value = "SELECT * FROM oo_store_commercial WHERE status_show = 0 AND status_remove = 0 AND commercial_id =?1 limit ?2,?3",nativeQuery = true)
    List<StoreCommercial> findByStatus(String commercialId, Integer count, Integer size);

    /**
     * 通过商户查找业态
     * @param storeId
     * @return
     */
    @Query(value = "SELECT * FROM oo_store_commercial WHERE status_remove = 0 AND store_id =?1",nativeQuery = true)
    List<StoreCommercial> findByStoreIdAndStatus(String storeId);


}
